<?php
use yii\helpers\Html;
use yii\helpers\Url;
use framework\helpers\Utils;
/* @var $this yii\web\View */
$this->title = '首页';
?>

	<div id="body_h" class="bcolor-eb">
		<section class="bannerPane">
		    <div class="swipe">
		        <ul id="slider">
		        <?php if ($Banners['list']){foreach ($Banners['list'] as $_K=>$_V){?>
		            <li <?php if ($_K==0){echo 'style="display:block;"';}?>>
		                <img width="100%" src="<?= 'http://47.88.161.66:8080'.$_V.'?tokenId='.Utils::getTokenId();?>" alt="" />
		            </li>
		        <?php }}?>
		        </ul>
		        <div id="pagenavi">
			         <?php if ($Banners['list']){foreach ($Banners['list'] as $_K=>$_V){?>
			            <a href="javascript:void(0);" <?php if ($_K==0){echo 'class="active"';}?>>
			                <?= $_K+1;?>
			            </a>
			        <?php }}?>
		        </div>
		    </div>
		</section>
		<div class="linedc-1"></div>
	<div class="wh-container">
		<section>
			<ul class="mould-1 clearfix">
				<li data-cato="mould-2list1" data-url='bidlist' class='current'><a href="/">竞标中</a></li>
				<li data-cato="mould-2list2" data-url='repaylist'><a href="/">还款中</a></li>
				<li data-cato="mould-2list3" data-url='finishlist'><a href="/">已完成</a></li>
			</ul>
			<ul id="mould-2list1" class="mould-2">
			<?php foreach ($BidList as $K1=>$V1){?>
				<li><!--循环li-->
					<div class="mould-2tit">
						<div class="mould-2info">
							<div>
								<p class="mould-2infoem">
									<?php if ($V1['type'] == 0){?>
									<span class="b-f small-div">抵</span>
								<?php }?>
								<?php if ($V1['type'] == 1){?>
									<span class="y-f small-div">秒</span>
								<?php }?>
									<?php if ($V1['type'] == 2){?>
									<span class="y-f small-div">其他</span>
								<?php }?>
								</p>
								<p class="mould-2infoti"><span><?= $V1['name'];?></span></p>
							</div>
						</div>
						<p class="mould-2time">
							<span class="font-10 color-85"><?= date('Y-m-d',strtotime($V1['time']));?> 发布</span>
						</p>
					</div>
					<div class="mould-2con clearfix">
						<div class="mould-2conleft">
							<ul>
								<li><p><span class="font-18 Greencolor font-b"><?= $V1['money'];?></span></p></li>
								<li><p>项目金额（元）</p></li>
								<li class="mould-2line"></li>
								<li><p><span class="font-15 Greencolor font-b"><?= $V1['duration'];?>个</span>月</p></li>
								<li><p>项目期限</p></li>
							</ul>
						</div>
						<div class='mould-2conmid'>
							<div class="circle">
							    <div class="pie_left"><div class="left"></div></div>
							    <div class="pie_right"><div class="right"></div></div>
							    <div class="mask Greencolor">
							    	<p><span class="font-14">￥<?= number_format($V1['investable']);?></span><br>可投资</p>
							    	<p class="hide"><span class="NUM"><?= $V1['investable']/$V1['money']*100;?></span>%</p>
							    </div>
							</div>
						</div>
						<div class="mould-2conright">
							<ul>
								<li class="mould-2jl"><img height="100%;" src="<?= Yii::getAlias('@web') . '/' ?>images/jiangli.png" alt="奖励"></li>
								<li><p class="y-f mould-2num"><span class="font-15"><?= $V1['reward'];?>%</span></p></li>
								<li class="mould-2line"></li>
								<li class="font-15 Greencolor font-b"><?= $V1['rate'];?>%</li>
								<li><p>年利率</p></li>
							</ul>
						</div>
					</div>
					<p class="mould-2bot"><a class="b-f" href="<?= Url::to(['detail','id'=>$V1['id']]);?>">查看详情</a></p>
				</li>
			<?php }?>
				<div class="loading hide" style="text-align:center"><img src="<?= Yii::getAlias('@web') . '/' ?>images/loading.gif" alt="" /></div>			
			</ul>
			<ul id="mould-2list2" class="mould-2">
			<?php foreach ($RepayList as $K2=>$V2){?>
				<li><!--循环li-->
					<div class="mould-2tit">
						<div class="mould-2info">
							<div>
								<p class="mould-2infoem">
								<?php if ($V2['type'] == 0){?>
									<span class="b-f small-div">抵</span>
								<?php }?>
								<?php if ($V2['type'] == 1){?>
									<span class="y-f small-div">秒</span>
								<?php }?>
									<?php if ($V2['type'] == 2){?>
									<span class="y-f small-div">其他</span>
								<?php }?>
								</p>
								<p class="mould-2infoti"><span><?= $V2['name'];?></span></p>
							</div>
						</div>
						<p class="mould-2time">
							<span class="font-10 color-85"><?= date('Y-m-d',strtotime($V2['time']));?> 发布</span>
						</p>
					</div>
					<div class="mould-2con clearfix">
						<div class="mould-2conleft">
							<ul>
								<li><p><span class="font-18 Greencolor font-b"><?= $V2['money'];?></span></p></li>
								<li><p>项目金额（元）</p></li>
								<li class="mould-2line"></li>
								<li><p><span class="font-15 Greencolor font-b"><?= $V2['duration'];?>个</span>月</p></li>
								<li><p>项目期限</p></li>
							</ul>
						</div>
						<div class='mould-2conmid'>
							<div class="circle">
							    <div class="pie_left"><div class="left"></div></div>
							    <div class="pie_right"><div class="right"></div></div>
							    <div class="mask Greencolor">
							    	<p class="mask-line1"><span class="font-14">还款中</span></p>
							    	<p class="hide"><span class="NUM">100</span>%</p>
							    </div>
							</div>
						</div>
						<div class="mould-2conright">
							<ul>
								<li class="mould-2jl"><img height="100%;" src="<?= Yii::getAlias('@web') . '/' ?>images/jiangli.png" alt="奖励"></li>
								<li><p class="y-f mould-2num"><span class="font-15"><?= $V2['reward'];?>%</span></p></li>
								<li class="mould-2line"></li>
								<li class="font-15 Greencolor font-b"><?= $V2['rate'];?>%</li>
								<li><p>年利率</p></li>
							</ul>
						</div>
					</div>
					<p class="mould-2bot"><a class="b-f" href="<?= Url::to('detail');?>">查看详情</a></p>
				</li>
				<?php }?>
			</ul>
			<ul id="mould-2list3" class="mould-2">
				<li>
					<div class="mould-2tit">
						<div class="mould-2info">
							<div>
								<p class="mould-2infoem">
									<span class="b-f small-div">抵</span>
									<span class="y-f small-div">秒</span>
								</p>
								<p class="mould-2infoti"><span>海淀黄庄房产抵押标20151015_02</span></p>
							</div>
						</div>
						<p class="mould-2time">
							<span class="font-10 color-85">2015-10-15 发布</span>
						</p>
					</div>
					<div class="mould-2con clearfix">
						<div class="mould-2conleft">
							<ul>
								<li><p><span class="font-18 Greencolor font-b">15</span>万</p></li>
								<li><p>项目金额（元）</p></li>
								<li class="mould-2line"></li>
								<li><p><span class="font-15 Greencolor font-b">3个</span>月</p></li>
								<li><p>项目期限</p></li>
							<ul>
						</div>
						<div class='mould-2conmid'>
							<div class="circle">
							    <div class="pie_left"><div class="left"></div></div>
							    <div class="pie_right"><div class="right"></div></div>
							    <div class="mask color-dc">
							    	<p class="mask-line1"><span class="font-14">已完成</span></p>
							    	<p class="hide"><span class="NUM">0</span>%</p>
							    </div>
							</div>
						</div>
						<div class="mould-2conright">
							<ul>
								<li class="mould-2jl2"><img height="100%;" src="<?= Yii::getAlias('@web') . '/' ?>images/jiangli2.png" alt="奖励"></li>
								<li class="mould-2line"></li>
								<li class="font-15 Greencolor font-b">18%</li>
								<li><p>年利率</p></li>
							<ul>
						</div>
					</div>
					<p class="mould-2bot"><a class="b-f" href="/">查看详情</a></p>
				</li>
			</ul>
		</section>
		</div>
		<div class="footer-h"></div>
	</div>
	<section id="footer">
		<ul class="footer-nav clearfix">
		    <li class="current-bot">
		        <a href="<?= Url::to('main');?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer1-on.png" alt="">
		            首页
		        </a>
		    </li>
		    <li>
		        <a href="<?= Url::to('member');?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer2.png" alt="">
		            我的账户
		        </a>
		    </li>
		    <li>
		        <a href="<?= Url::to(['company/about']);?>">
		            <img src="<?= Yii::getAlias('@web') . '/' ?>images/footer3.png" alt="">
		            关于我们
		        </a>
		    </li>
		</ul>
	</section>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/reset.js"></script>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/run.js"></script>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/touchscroll.js"></script>
<script src="<?= Yii::getAlias('@web') . '/' ?>js/touchscroll.dev.js"></script>
<script src='<?= Yii::getAlias('@web') . '/' ?>js/zepto.min.js'></script>
	<script>
	$(function($) {
	    var UA=window.navigator.userAgent;  //使用设备
	    var CLICK="click";
	    if(/ipad|iphone|android/.test(UA)){   //判断使用设备
	        CLICK="tap";
	    }
		$(".mould-2conmid").each(function(){
			var T_H = $(this).height();
				T_Hcircle = $(this).find(".circle").height();
			$(this).find(".circle").css("margin-top",(T_H-T_Hcircle)/2);
		});
		$(".mould-2").each(function(){
			$(this).addClass("hide");
		})
	   
		var id='mould-2list1';
		var url = 'bidlist';
        var page=1;//当前页
        var ul_obj = $('#'+id); //数据加载的位置
	    var catoFram=$(".mould-2");
	    var subNav=$(".mould-1 li");
	    $("#mould-2list1").removeClass("hide");
	    subNav[0].className += " current" ;
	    subNav[CLICK](function(event){
            event.preventDefault();
            $(".bodyA").show();
	        var _this=$(this);
	        var id=_this.data("cato"); 
	        var cur=$("#"+id);
	        ul_obj = $('#'+id);
			url = _this.data("url");
			page=1;
	        subNav.removeClass("current");
	        _this.addClass("current");
	        catoFram.addClass("hide");
	        cur.scrollTop(0);        
	        cur.removeClass("hide");
	        $.ajax({
                type: 'GET',
                url: url+'?page='+page+'&num=7',
                dataType: 'text',
                success: function(json){
					var dataObj=eval("("+json+")");
					var type;
			        $('#'+id).find("li").remove();
					$.each(dataObj.list,function(i,val){
						if(url == 'bidlist')
						{
							var investable = val.investable/val.money*100;
							var temp = '<div class="mask Greencolor"><p><span class="font-14">￥'+val.investable+'</span><br>可投资</p><p class="hide"><span class="NUM">'+investable+'</span>%</p></div>';
						}
						else if(url == 'repaylist')
						{
							var temp = '<div class="mask Greencolor"><p class="mask-line1"><span class="font-14">还款中</span></p><p class="hide"><span class="NUM">100</span>%</p></div>';
						}
						else if(url == 'finishlist')
						{
							var temp = '<div class="mask color-dc"><p class="mask-line1"><span class="font-14">已完成</span></p><p class="hide"><span class="NUM">0</span>%</p></div>';
						}
						
						if(val.type == 0){type='<span class="b-f small-div">抵</span>';}else if(val.type == 1){type='<span class="y-f small-div">秒</span>';}else if(val.type == 2){type='<span class="y-f small-div">其他</span>';}
						ul_obj.append('<li><div class="mould-2tit"><div class="mould-2info"><div><p class="mould-2infoem">'+type+'</p><p class="mould-2infoti"><span>'+val.name+'</span></p></div></div><p class="mould-2time"><span class="font-10 color-85">'+val.time.substr(0,10)+' 发布</span></p></div><div class="mould-2con clearfix"><div class="mould-2conleft"><ul><li><p><span class="font-18 Greencolor font-b">'+val.money+'</span></p></li><li><p>项目金额（元）</p></li><li class="mould-2line"></li><li><p><span class="font-15 Greencolor font-b">'+val.duration+'个</span>月</p></li><li><p>项目期限</p></li><ul></div><div class="mould-2conmid"><div class="circle"><div class="pie_left"><div class="left"></div></div><div class="pie_right"><div class="right"></div></div>'+temp+'</div></div><div class="mould-2conright"><ul><li class="mould-2jl"><img height="100%;" src='+'<?= Yii::getAlias("@web") . "/" ?>images/jiangli.png'+' alt="奖励"></li><li><p class="y-f mould-2num"><span class="font-15">'+val.reward+'%</span></p></li><li class="mould-2line"></li><li class="font-15 Greencolor font-b">'+val.rate+'%</li><li><p>年利率</p></li><ul></div></div><p class="mould-2bot"><a class="b-f" href='+'<?= Url::to("detail");?>?id='+val.id+'>查看详情</a></p></li>');
					});
                    
                    $(".loading").remove();//删除加载图片
                    ajax=!1;//注明已经完成ajax加载
                    //加载可投资进度条
                    $('.circle').each(function(index, el) {
            	        var num = $(this).find('.NUM').text() * 3.6;
            	        if (num<=180) {
            	            $(this).find('.right').css('transform', "rotate(" + num + "deg)");
            	        } else {
            	            $(this).find('.right').css('transform', "rotate(180deg)");
            	            $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)");
            	        };
            	    });
                },
                error: function(xhr, type){
                    $(".loading").html("暂无内容！");
                }
            });
            $(".bodyA").hide();
	    });
	  //需要 zepto.js支持
        var ajax=!1;//是否加载中
        Zepto(function($){
            $(window).scroll(function(){
                if(($(window).scrollTop() + $(window).height() > $(document).height()-40) && !ajax){
                    //滚动条拉到离底40像素内，而且没ajax中，而且没超过总页数

                    page++;//当前页增加1
                    ajax=!0;//注明开始ajax加载中
                    $(".wh-container").append('<div class="loading" style="text-align:center;  font-size:16px; color:#999; "><img  style="vertical-align: middle; margin-right:10px;" src="<?= yii::getAlias('@web').'/' ?>images/loading1.gif" alt="" />上拉加载</div> ');//出现加载图片
					
                    $.ajax({
                        type: 'GET',
                        url: url+'?page='+page+'&num=7',
                        dataType: 'text',
                        success: function(json){
							var dataObj=eval("("+json+")");
							var type;
							if(dataObj.list)
							{
								$.each(dataObj.list,function(i,val){
									if(url == 'bidlist')
									{
										var investable = val.investable/val.money*100;
										var temp = '<div class="mask Greencolor"><p><span class="font-14">￥'+val.investable+'</span><br>可投资</p><p class="hide"><span class="NUM">'+investable+'</span>%</p></div>';
									}
									else if(url == 'repaylist')
									{
										var temp = '<div class="mask Greencolor"><p class="mask-line1"><span class="font-14">还款中</span></p><p class="hide"><span class="NUM">100</span>%</p></div>';
									}
									else if(url == 'finishlist')
									{
										var temp = '<div class="mask color-dc"><p class="mask-line1"><span class="font-14">已完成</span></p><p class="hide"><span class="NUM">0</span>%</p></div>';
									}
									
									if(val.type == 0){type='<span class="b-f small-div">抵</span>';}else if(val.type == 1){type='<span class="y-f small-div">秒</span>';}else if(val.type == 2){type='<span class="y-f small-div">其他</span>';}
									ul_obj.append('<li><div class="mould-2tit"><div class="mould-2info"><div><p class="mould-2infoem">'+type+'</p><p class="mould-2infoti"><span>'+val.name+'</span></p></div></div><p class="mould-2time"><span class="font-10 color-85">'+val.time.substr(0,10)+' 发布</span></p></div><div class="mould-2con clearfix"><div class="mould-2conleft"><ul><li><p><span class="font-18 Greencolor font-b">'+val.money+'</span></p></li><li><p>项目金额（元）</p></li><li class="mould-2line"></li><li><p><span class="font-15 Greencolor font-b">'+val.duration+'个</span>月</p></li><li><p>项目期限</p></li><ul></div><div class="mould-2conmid"><div class="circle"><div class="pie_left"><div class="left"></div></div><div class="pie_right"><div class="right"></div></div>'+temp+'</div></div><div class="mould-2conright"><ul><li class="mould-2jl"><img height="100%;" src='+'<?= Yii::getAlias("@web") . "/" ?>images/jiangli.png'+' alt="奖励"></li><li><p class="y-f mould-2num"><span class="font-15">'+val.reward+'%</span></p></li><li class="mould-2line"></li><li class="font-15 Greencolor font-b">'+val.rate+'%</li><li><p>年利率</p></li><ul></div></div><p class="mould-2bot"><a class="b-f" href='+'<?= Url::to("detail");?>?id='+val.id+'>查看详情</a></p></li>');
								});
								$(".loading").remove();//删除加载图片
	                            ajax=!1;//注明已经完成ajax加载
							}
							else
							{
								$(".loading").html("暂无内容！");
	                            ajax=!0;
							}

                            //加载可投资进度条
                            $('.circle').each(function(index, el) {
                    	        var num = $(this).find('.NUM').text() * 3.6;
                    	        if (num<=180) {
                    	            $(this).find('.right').css('transform', "rotate(" + num + "deg)");
                    	        } else {
                    	            $(this).find('.right').css('transform', "rotate(180deg)");
                    	            $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)");
                    	        };
                    	    });
                        },
                        error: function(xhr, type){
                            $(".loading").html("暂无内容！");
                            ajax=!0;
                        }
                    });
                }
            });
        });
        $('.circle').each(function(index, el) {
	        var num = $(this).find('.NUM').text() * 3.6;
	        if (num<=180) {
	            $(this).find('.right').css('transform', "rotate(" + num + "deg)");
	        } else {
	            $(this).find('.right').css('transform', "rotate(180deg)");
	            $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)");
	        };
	    });
		$(".bodyA").hide();
	});
	</script>